#include<stdio.h>
#include<math.h>
int IsPrimer(int x)
{
    if(x == 1) return 0;
    if(x == 2) return 1;
    int flag = 0;
    int q = int(sqrt(x));
    for (int i = 2; i <= q; i++)
    {
        if (x % i == 0)
            flag = 1;
    }
    if (flag == 0)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}
int main()
{
    //freopen("in.txt","r",stdin);
    int x[105];
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n; i++) 
    {
        scanf("%d",&x[i]);
        if(IsPrimer(x[i])) printf("%d ",x[i]);
    }   
}